<template>
  <div>
    <van-nav-bar title="车辆信息" left-text="返回" left-arrow @click-left="back" />
    <van-form @submit="onSubmit">
      <van-field v-model="carnumber" name="carnumber" label="车牌号" placeholder="请输入车牌号"
        :rules="[{ required: true, message: '请输入车牌号' }]" />
      <van-field v-model="cartype" name="cartype" label="车型" placeholder="请输入车型"
        :rules="[{ required: true, message: '请输入车型' }]" />
      <div style="margin: 16px;">
        <van-button round block type="info" native-type="submit">提交</van-button>
      </div>
    </van-form>
  </div>

</template>

<script>
import mixin from "@/mixin/flag";
import { addcar } from "./Service"
export default {
  mixins: [mixin],
  data() {
    return {
      carnumber: '',
      cartype: '',
    };
  },
  methods: {
    back() {
      this.$router.go(-1);
    },
    async onSubmit(values) {
      console.log('submit', values);
      console.log(this.carnumber, this.cartype);
      let res = await addcar({
        plateNo: this.carnumber,
        type: this.cartype
      })
      if(res.data.code==200){
      this.$router.push("/park/mine");
      }else{
        this.$toast.fail(res.data.msg)
      }
      console.log(res);
      // this.$router.push('/park/mine');
    },
  },
}
</script>

<style>

</style>